def sravni(a):
    if a=='zero': return '0'
    elif a=='one': return '1'
    elif a=='two': return '2'
    elif a=='three': return '3'
    elif a=='four': return '4'
    elif a=='five': return '5'
    elif a=='six': return '6'
    elif a=='seven': return '7'
    elif a=='eight': return '8'
    elif a=='nine': return '9'
    else: return "False"
def p(num):
    if num < 2:
        return False
    for i in range(2, int(num ** 0.5) + 1):
        if num % i == 0:
            return False
    return True

def f(num):
    l = num - 1
    u = num + 1

    while True:
        if p(l):
            return l
        elif p(u):
            return u
        else:
            l -= 1
            u += 1





nums = ['zеro', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
stroka_nums = input()
num_str = ''
colvo = 0
helps = stroka_nums
a=stroka_nums.rfind(' ')
helpm = stroka_nums[a+1:]
a=0
for i in range(len(stroka_nums)):
    a = helps.find(' ')
    if a>0:
        colvo+=1
    if a<=0:break
    helps = helps[a+1:]
a = 0
helps = stroka_nums
if colvo==2:
    for i in range(colvo):
        a = helps.find(' ')
        help_str = helps[:a]
        if sravni(help_str)!="False":
            num_str+=sravni(help_str)
            helps=helps[a+1:]
if sravni(helpm)!="False":
    num_str+=sravni(helpm)
    num=int(num_str)
    if num>=100:
        print(f(num))
else: print("Wrong input")
if num<100: print("Wrong input")
